//接口统一管理
import requests from "./request";
import mockRequests from './mockAjax'
//三级联动的接口
///api/product/getBaseCategoryList get 无参数
export const reqCategoryList = ()=>{
    //发请求：axios发请求返回的结果是Promise对象
    return requests({
        url:'/product/getBaseCategoryList',
        method:'get'
    })
}
//获取banner（Home首页轮播图接口）
export const reqGetBannerList=()=>{
    return mockRequests.get('/banner')
}
//获取floors数据
export const reqGetFloorList=()=>{
    return mockRequests.get('/floors')
}
//获取搜索模块数据  地址：/api/list 请求方式是post  需要带参数
// {
//     "category3Id": "61",
//     "categoryName": "手机",
//     "keyword": "小米",
//     "order": "1:desc",
//     "pageNo": 1,
//     "pageSize": 10,
//     "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
//     "trademark": "4:小米"
//   }
export const reqGetSearchInfo=(params)=>{
    return requests.post('/list',params)
    // requests({
    //     url:'/list',
    //     method:'post',
    //     data:params
    // })
}  
//获取商品详情信息的接口  /api/item/{ skuId } get
export const reqGetDetailList=(skuId)=>{
    return requests({
        url:`/item/${skuId}`,
        method:'get'
    })
}
//将产品添加到购物车中（获取更新某一个产品的个数）
export const reqAddOrUpdateShopCart=(skuId,skuNum)=>{
  return requests.post(`/cart/addToCart/${skuId}/${skuNum}`)
}
//购物车接口 /api/cart/cartList
export const reqShopCartList=()=>{
    return requests.get('/cart/cartList')
}
//删除购物车商品的接口 /api/cart/deleteCart/{skuId}
export const reqDeleteCartById=(skuId)=>{
    return requests.delete(`/cart/deleteCart/${skuId}`)
}
//购物车商品切换选中状态 /api/cart/checkCart/{skuID}/{isChecked}
export const reqCheckCart=(skuId,isChecked)=>{
    return requests.get(`/cart/checkCart/${skuId}/${isChecked}`)
}


//用户api
//获取验证码api /api/user/passport/sendCode/{phone}
export const reqSendCode=(phone)=>{
    return requests.get(`/user/passport/sendCode/${phone}`)
}
//注册 /api/user/passport/register  post
export const reqUserRegister =(user)=>{
    return requests.post('/user/passport/register',user)
}
//登录 /api/user/passport/login  post
export const reqUserLogin =(user)=>{
    return requests.post('/user/passport/login',user)
}
//获取用户信息 /api/user/passport/auth/getUserInfo
export const reqUserInfoList=()=>{
    return requests.get('/user/passport/auth/getUserInfo')
}
//退出登录 /api/user/passport/logout get
export const reqLogout =()=>{
    return requests.get('/user/passport/logout')
}

//结算商品页面 获取用户地址信息接口 /api/user/userAddress/auth/findUserAddressList  get
export const reqUserAddressList=()=>{
    return requests.get('/user/userAddress/auth/findUserAddressList')
}
//获取商品清单  /api/order/auth/trade  
export const reqOrderInfo=()=>{
    return requests.get('/order/auth/trade')
}

//提交订单  /api/order/auth/submitOrder?tradeNo={tradeNo}  post
export const  submitOrder=(tradeNo,data)=>{
    return requests.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`,data)
}
//获取订单支付信息  /api/payment/weixin/createNative/{orderId} get
export const  reqPayInfo=(orderId)=>{
    return requests.get(`/payment/weixin/createNative/${orderId}`)
}
//获取支付订单状态 /api/payment/weixin/queryPayStatus/{orderId}  get
export const  reqPayStatus=(orderId)=>{
    return requests.get(`/payment/weixin/queryPayStatus/${orderId}`)
}
//获取个人中心的数据 列表分页 /api/order/auth/{page}/{limit}  get
export  const  reqAuth=(page,limit)=>{
    return requests.get(`/order/auth/${page}/${limit}`);
}